package com.hu.zhcc.shiro.controller;

import com.hu.zhcc.common.entity.Page;
import com.hu.zhcc.shiro.entity.bo.HMemberofthefile;
import com.hu.zhcc.shiro.service.HMemberofthefileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;


/**
 * 会员档案
 *
 */
@RestController
@RequestMapping("/member")
public class HMemberofthefileController {
    
    @Autowired
    private HMemberofthefileService hMemberofthefileService;

    @GetMapping("/memberAll")
    private Page<HMemberofthefile> findAll(int offset, int limit ,String value) {
        return hMemberofthefileService.findhmList(offset,limit,value);
    }

    @GetMapping("/memberKey/{id}")
    private HMemberofthefile getMemberById(@PathVariable("id") int id) {
        return hMemberofthefileService.selectByPrimaryKey(id);
    }

    @PostMapping("/addMember")
    private int addfind(@RequestBody HMemberofthefile hMemberofthefile){
        Date now = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        hMemberofthefile.sethRegistration(dateFormat.format( now ));
        return hMemberofthefileService.insertSelective(hMemberofthefile);
    }

    @DeleteMapping("/removeMember/{id}")
    private int removeMember(@PathVariable("id") int id) {
        return hMemberofthefileService.deleteByPrimaryKey(id);
    }

    @PutMapping("/updateMember")
    private int updateMember(@RequestBody HMemberofthefile hMemberofthefile) {
        return hMemberofthefileService.updateByPrimaryKeySelective(hMemberofthefile);
    }

    @PostMapping("/login")
    private HMemberofthefile login(@RequestBody HMemberofthefile hMemberofthefile){
        return hMemberofthefileService.login(hMemberofthefile);
    }
}
